package com.spring.springboot.rabbitmq.test;

import com.alibaba.fastjson.JSONObject;
import com.spring.springboot.dto.User;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 项目名称: java_algorithm
 * @ClassName MessageProduct
 * @Description
 * @Author huipanxing huipanxing@chinasofti.com   @Date 2022/6/8 19:04
 */
@Component
public class MessageConsume {

    @RabbitListener(queues = "simple-queue")
    public void receiveMessage1(String msg){
        System.out.println("1---"+msg);
    }

    @RabbitListener(queues = "simple-queue")
    public void receiveMessage2(String msg){
        System.out.println("2---"+msg);
    }

//    @RabbitListener(queues = "simple-queue")
//    public void receiveMessage(Message msg){
//        String string = new String(msg.getBody());
//        User user = JSONObject.parseObject(string, User.class);
//        System.out.println(user);
//    }

    @RabbitListener(queues = "springboot-queue1")
    public void receiveMessage3(String msg){
        System.out.println("1---"+msg);
    }

    @RabbitListener(queues = "springboot-queue2")
    public void receiveMessage4(String msg){
        System.out.println("2---"+msg);
    }

    @RabbitListener(queues = "springboot-queue3")
    public void receiveMessage5(String msg){
        System.out.println("3---"+msg);
    }

    @RabbitListener(queues = "springboot-queue4")
    public void receiveMessage6(String msg){
        System.out.println("4---"+msg);
    }
}
